def read_file():
    a = 10
    b = 0
    try:
        rst = a / b
        print(rst)

        print("异常之后的代码")
        return rst
    except ZeroDivisionError as e:
        # print(e)
        print("除数不能为0")
    finally:
        print("finally里关闭资源")


def write_file():
    f = open("haha.txt", "w")
    try:
        a = 10
        b = 0
        rst = a / b
        f.write(str(rst))
    except Exception as e:
        print("出现异常，", e, type(e))
    finally:
        f.close()
        print("关闭资源")


# print(read_file())
write_file()
